#!/usr/bin/perl -w
use warnings;
use strict;

my @ram_tests = qw(RAM_one RAM_zero RAM_checkbox);
my @reg_tests = qw(Register_read);

my $ram_all = sub {
    my ($ic) = @_;
    for my $test (@ram_tests) {
        return 'F' unless $ic->{$test} eq 'P';
    }
    return 'P';
};

my $reg_and_ram = sub {
    my ($ic) = @_;
    for my $test (@ram_tests, @reg_tests) {
        return 'F' unless $ic->{$test} eq 'P';
    }
    return 'P';
};

my $repo = [
    #
    +{ # TMA item begin
        'id'    => 'bin-1', 'exclude' => [],
        'desc'  => undef,
        'specs' => [ # the specs
            ## format:
            ## <Bin>, <Item>, <Operator>, <Operands ...>
            ## <Bin>: greater than 1, 1 is reserved as pass bin
            ## <Item>: a. item name;
            ##         b. may be an array ref (tuple), first is the item name,
            ##            second is the code ref for calculating the value
            ## <Operator>: op name
            ## <Operands...>: one or two operands
            [ 2, 'Idd_reset',      'n_lt',      0.1       ],
            [ 3, 'VDD18C_reset',   'n_ge_le',   1.6,  2.0 ],
            [ 4, 'Register_read',  's_eq',      'P'       ],
            [ 4, 'RAM_one',        's_eq',      'P'       ],
            [ 4, 'RAM_zero',       's_eq',      'P'       ],
            [ 4, 'RAM_checkbox',   's_eq',      'P'       ],
            [ 4, ['RAM_all', $ram_all], 's_eq', 'P'       ],
            [ 4, ['Register_and_RAM', $reg_and_ram], 's_eq', 'P' ],
            [ 5, 'Idd_display',    'n_lt',      8.0       ],
            [ 5, 'VGHC_display',   'n_ge',     12.0       ],
            [ 5, 'VGLC_display',   'n_le',     -5.0       ],
            [ 5, 'VCOMH_display',  'n_ge',      3.1       ],
            [ 5, 'VCOMH_display',  'n_le',     -0.9       ],
            [ 6, 'DisplayTiming',  's_eq',     'P'        ],
        ]
    }, # TMA item end
]; # end of yield repository

## returning
$repo;
